<?php 
class newLevelsAction extends AdminMaster{
	public function execute($request){
		$this->data['navigation']	= __('module_educations',null,'menu').' › '. __('module_educations_action_levels',null,'menu');
		$this->formData				= $request->getParameter('MasterEducationLevels');	//get form data from add new || edit page
		
		
		$this->addRecord();
		$this->setVar('data', $this->data);
	}
	
	/*********************************************************************************
	*
	* ADD NEW
	* 
	**********************************************************************************/
	private function addRecord(){
		$this->data['navigation'].=' › '. __('nav_add_new',null,'table_list');
		$this->data['button_action'] = __('button_add',null,'table_list');
		$this->setTemplate('newLevelsForm');
		
		$form = new MasterEducationLevelsFForm();
		if($this->data['is_post']){
			$form->bind($this->formData);
			if($form->isValid()){
				$product_id = MasterEducationLevelsTable::insert($this->formData);
				if($product_id > 0){
					$this->data['result']	= __('add_new_success', null, 'major_cates');
					$form = new MasterEducationLevelsFForm();
				}else{
					$this->data['result']	= sprintf(__('add_new_error', null, 'table_list'), sfConfig::get('app_email_admin')) ;
				}
					
			}
		}
		$this->setVar('form', $form);
	}
}